package com.java.mapper;

import com.java.pojo.*;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * description:描述
 * author:作者
 * time:2020/11/23 23:11
 */
public interface StudentFunctionMapper {

    /**
     * 通过微信号查看学生个人信息
     * @param Wxid
     * @return
     */
    @Select("SELECT * FROM student_info WHERE studentWxid=#{arg0}")
    Student_info selectStudentInfoByWxid(String Wxid);

    /**
     * 修改学生信息
     * @param student_info
     * @return
     */
    @Update("UPDATE student_info SET studentName=#{studentName},sno=#{sno},studentClass=#{studentClass},image_path=#{image_path} WHERE studentWxid=#{studentWxid}")
    int updateStudentInfo(Student_info student_info);

    /**
     * 获取学生课程信息
     * @param Wxid
     * @return
     */
    @Select("SELECT * FROM student_course where studentWxid=#{arg0}")
    List<CourseList> selectStudentCourse(String Wxid);

    /**
     * 获取所有课程
     * @param
     * @return
     */
    @Select("SELECT * FROM all_course")
    List<CourseList> selectAllCourse();


    /**
     * 获取课程详细信息
     * @param
     * @return
     */
    @Select("SELECT * FROM course_detail where courseId=#{arg0}")
    Course_detail selectCourseDetail(String courseId);

    /**
     * 学生添加课程
     * @param
     * @return
     */

    @Insert("INSERT INTO student_course_relation (UUID,course_uuid,student_uuid) VALUES (null,#{arg1},#{arg0})")
    Long addStudentCourseInfo(String studentUuid, String courseId);

    /**
     * 学生根据微信id获取Uuid
     * @param
     * @return
     */
    @Select("SELECT uuid FROM student_info where studentWxid=#{arg0}")
    String getUuidByWxid(String studentWxid);

    /**
     * 学生删除课程
     * @param
     * @return
     */
    @Delete("DELETE FROM student_course_relation WHERE student_uuid=#{arg0} AND course_uuid=#{arg1}")
    int deleteStudentCourseInfo(String studentUuid, String courseId);

    /**
     * 签到成功
     * @param
     * @return
     */
    @Insert("INSERT INTO check_info VALUES (#{uuid},#{courseId},#{studentId},#{courseNum},#{checkTime})")
 //   @Options(useGeneratedKeys=true, keyProperty="uuid")
    int checkSuccess(CheckInfo checkInfo);

    /**
     * 获取自身签到情况
     * @param
     * @return
     */
    @Select("select count(*) from check_info c where c.course_id=#{courseId} and c.student_id=#{studentId} and c.course_num=#{courseNum}")
    int getCheckInfo(CheckInfo checkInfo);






}
